// 钠 Na
// 钙 Ca
// 铁 Fe
// 锌 Zn
// 磷 P
// 铜 Cu
// 碘 I
// 硒 Se
// 铬 Cr
// 镁 Mg
// 钼 Mo
// 钾 K
// 硫 S
// 氯 CI
// 锰 Mn
// 钴 Co

// b1 b2 b3 b5 b6 b7 b9 b12 c
// a d e k


// 胡萝卜 苹果 奶酪 蜂蜜
const Items = {
    "roast_pig_meat_normal": {
        name: "烤猪肉",
        price: 18,
        type: "food",
        drink: false,
        unit: "块",
        weight: 0.2,
        space: 0.05,
        nutrition: {
            "base": {
                "water": 0.13,
                "unUse": 0.354,
                "carbs": 0.192,
                "sugar": 0.001,
                "fiber": 0.0022,
                "alcohol": 0,
                "fat": 0.0742,
                "protein": 0.1951
            },
            "element": {
                "b1": 0.54,
                "b2": 0.1,
                "b6": 0.32,
                "e": 0.34,
                "Ca": 6,
                "P": 162,
                "K": 204,
                "Mg": 16,
                "Na": 59,
                "Fe": 1.6,
                "Zn": 2.06,
                "Se": 0.012,
                "Cu": 0.06,
                "Mn": 0.03,
            }
        }
    },
    "shu_ji_yu": {
        name: "熟鲫鱼",
        price: 23,
        type: "food",
        drink: false,
        unit: "块",
        weight: 0.5,
        space: 0.1,
        nutrition: {
            "base": {
                "water": 0.4,
                "unUse": 0.15,
                "carbs": 0.15,
                "sugar": 0.001,
                "fiber": 0.002,
                "alcohol": 0,
                "fat": 0.017,
                "protein": 0.21
            },
            "element": {
                "a": 0.042,
                "b1": 0.11,
                "b2": 0.14,
                "b12": 0.42,
                "e": 1.2,
                "d": 0.635,
                "Ca": 431,
                "P": 150,
                "K": 225,
                "Mg": 55,
                "Na": 60,
                "Fe": 8.1,
                "Zn": 8.3,
                "Se": 0.29,
                "Cu": 0.06,
                "Mn": 0.03,
            }
        }
    },
    "black_bread": {
        name: "黑面包",
        price: 6,
        type: "food",
        drink: false,
        unit: "块",
        weight: 0.4,
        space: 0.200,
        nutrition: {
            "base": {
                "water": 0.36,
                "unUse": 0.129,
                "carbs": 0.28,
                "sugar": 0.12,
                "fiber": 0,
                "alcohol": 0,
                "fat": 0.032,
                "protein": 0.009
            },
            "element": {
                "b1": 0.2,
                "b2": 0.1,
                "b6": 0.135,
                "c": 0.4,
                "e": 0.7,
                "Na": 15,
                "P": 147,
                "K": 200,
                "Ca": 16,
                "Fe": 2.1,
                "Zn": 1.075,
                "Se": 0.004575,
                "Cu": 0.225,
                "Mn": 0.785
            }
        }
    },
    "white_bread": {
        name: "白面包",
        price: 16,
        type: "food",
        drink: false,
        unit: "块",
        weight: 0.4,
        space: 0.200,
        nutrition: {
            "base": {
                "water": 0.34,
                "unUse": 0.054,
                "carbs": 0.31,
                "sugar": 0.15,
                "fiber": 0,
                "alcohol": 0,
                "fat": 0.033,
                "protein": 0.01
            },
            "element": {
                "b1": 0.51,
                "b2": 0.25,
                "b6": 0.08,
                "c": 0.4,
                "e": 0.7,
                "Na": 135,
                "Mg": 26,
                "P": 103,
                "K": 127,
                "Ca": 36,
                "Fe": 4.9,
                "Zn": 1.1,
                "Se": 0.004575,
                "Cu": 0.225,
                "Mn": 0.785
            }
        }
    },
    "pea": {
        name: "豌豆",
        price: 18,
        type: "food",
        drink: false,
        unit: "斤",
        weight: 0.5,
        space: 0.32,
        nutrition: {
            "base": {
                "water": 0.13,
                "unUse": 0.054,
                "carbs": 0.47,
                "sugar": 0.001,
                "fiber": 0.001,
                "alcohol": 0,
                "fat": 0.06,
                "protein": 0.217
            },
            "element": {
                "a": 0.1,
                "b1": 0.74,
                "b2": 0.02,
                "b6": 0.12,
                "c": 24,
                "e": 0.21,
                "Na": 57,
                "Mg": 118,
                "P": 259,
                "K": 823,
                "Ca": 97,
                "Fe": 4.9,
                "Zn": 2.35,
                "Se": 0.00169,
                "Cu": 0.47,
                "Mn": 1.15
            }
        }
    },
    "chickpeas": {
        name: "鹰嘴豆",
        price: 18,
        type: "food",
        drink: false,
        unit: "斤",
        weight: 0.5,
        space: 0.32,
        nutrition: {
            "base": {
                "water": 0.13,
                "unUse": 0.054,
                "carbs": 0.43,
                "sugar": 0.002,
                "fiber": 0.122,
                "alcohol": 0,
                "fat": 0.06,
                "protein": 0.19
            },
            "element": {
                "a": 0.003,
                "b1": 0.48,
                "b2": 0.21,
                "b6": 0.12,
                "c": 4,
                "e": 0.82,
                "k": 0.009,
                "Ca": 105,
                "Mg": 115,
                "Fe": 6.2,
                "Zn": 3.43,
                "K": 875,
            }
        }
    },
    "egg": {
        name: "鸡蛋",
        price: 18,
        type: "food",
        drink: false,
        unit: "颗",
        weight: 0.05,
        space: 0.03,
        nutrition: {
            "base": {
                "water": 0.26,
                "unUse": 0.054,
                "carbs": 0.015,
                "sugar": 0.001,
                "fiber": 0.001,
                "alcohol": 0,
                "fat": 0.09,
                "protein": 0.127
            },
            "element": {
                "a": 0.1,
                "b1": 0.74,
                "b2": 0.02,
                "b6": 0.12,
                "c": 24,
                "e": 0.21,
                "Na": 57,
                "Mg": 118,
                "P": 259,
                "K": 823,
                "Ca": 97,
                "Fe": 4.9,
                "Zn": 2.35,
                "Se": 0.00169,
                "Cu": 0.47,
                "Mn": 1.15
            }
        }
    }
}





function calcCalorie(item) {
    let nutrition = item.nutrition.base
    let value = item.weight * 1000
    let {
        carbs,
        sugar,
        fat,
        protein
    } = nutrition
    let carbs_value = value * carbs
    let sugar_value = value * sugar
    let fat_value = value * fat
    let car = (carbs_value * 1.428 + sugar_value) * 4
    car += fat_value * 9
    // console.log(item.name, value, car.toFixed(2) - 0, (car / (value / 100)).toFixed(2) - 0);
    console.log(item.name, "热量:", (car / (value / 100)).toFixed(2) - 0, "蛋白质:", (protein*100).toFixed(2)-0);
}


for (const foodKey in Items) {
    const foodInfo = Items[foodKey]
    calcCalorie(foodInfo)

}